package com.ruoyi.web.controller.durian;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.durian.domain.LlUserFriend;
import com.ruoyi.durian.domain.LlUserOpenTaxi;
import com.ruoyi.durian.service.LlCouponExchangeService;
import com.ruoyi.durian.service.LlUserFriendService;
import com.ruoyi.durian.service.LlUserOpenTaxiService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 个人中心控制器
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/person")
public class PerosnController extends BaseController {

    @Resource
    private LlCouponExchangeService llCouponExchangeService;

    @Resource
    private LlUserFriendService llUserFriendService;

    @Resource
    private LlUserOpenTaxiService llUserOpenTaxiService;

    /**
     * 券码兑换
     *
     * @param code 兑换码
     * @return
     */
    @PostMapping("/exchange")
    public AjaxResult exchange(String code) {
        return llCouponExchangeService.exchange(code);
    }

    /**
     * 添加代叫乘客
     *
     * @return
     */
    @PostMapping("/saveOrUpdateFriend")
    public AjaxResult saveOrUpdateFriend(@RequestBody LlUserFriend llUserFriend) {
        return llUserFriendService.saveOrUpdateFriend(llUserFriend);
    }

    /**
     * 朋友列表
     *
     * @return
     */
    @GetMapping("/selectFriendList")
    public TableDataInfo selectFriendList() {
        startPage();
        return getDataTable(llUserFriendService.selectFriendList());
    }

    /**
     * 回显乘客代叫朋友信息
     *
     * @param id
     * @return
     */
    @GetMapping("/selectFriendById/{id}")
    public AjaxResult selectFriendById(@PathVariable Integer id) {
        return llUserFriendService.selectFriendById(id);
    }

    /**
     * 关闭开启朋友代叫
     *
     * @return
     */
    @PostMapping("/openOrCloceTaxi")
    public AjaxResult openOrCloceTaxi(@RequestBody LlUserOpenTaxi llUserOpenTaxi) {
        return llUserOpenTaxiService.openOrCloceTaxi(llUserOpenTaxi);
    }

    /**
     * 查询代叫状态
     * @return
     */
    @GetMapping("/getRecallStatus")
    public AjaxResult getRecallStatus() {
        return llUserOpenTaxiService.getRecallStatus();
    }

}
